<?php
use PHPUpdater\cVersion;
use PHPLog\Install_File;
use PHPLog\Install\Common;
require_once "../Common/CommonFunctions.php";

$int_Ver_Maj	= 0;
$int_Ver_Min	= 1;
$int_Ver_Beta	= 1;

$GLOBALS["InstallBase"] = Common\clean_Path(dirname(dirname(dirname(dirname(dirname(__FILE__))))));

$str_History = Common\clean_Path($GLOBALS["InstallBase"] . "/PHP_Updater/code/Classes/History/cHistory.php");
$str_Version = Common\clean_Path($GLOBALS["InstallBase"] . "/PHP_Updater/code/Classes/cVersion.php");

//Set the install Path
$GLOBALS ["InstallPath"] = Common\clean_Path($_POST ["C_STR_CODE"]."/Code");
$str_CodeInfo = Common\clean_Path($GLOBALS ["InstallPath"] . "/cCodeInfo.php");

include $str_CodeInfo;
if(!class_exists("/cCodeInfo"))
{
	require_once  dirname(dirname(dirname(dirname(__FILE__))))."/Code/cCodeInfo.php";
}

require_once $str_History;
require_once $str_Version;

//Set Global Variables
$GLOBALS ["InstallPath"] = Common\clean_Path(PHPLog\cCodeInfo::C_STR_CODE."/Code");

print("<h3>Copy Log Files</h3>");
print("<b>Install Path</b> - " . $GLOBALS ["InstallPath"] . "<br/>");

$str_History_Path = Common\clean_Path(dirname($GLOBALS ["InstallPath"]) . "/Setup/Install_History.xml");

Common\open_History($str_History_Path);
Common\set_App_Name("PHP_Log");
Common\set_Version(new cVersion($int_Ver_Maj,$int_Ver_Min,$int_Ver_Beta));

print("Copy Log Files...<br/>");

copy_Log_Files();

print("&nbsp; - Successful<br/>");

Common\save_History();

function copy_Log_Files()
{
	//Copy Abstract Classes
	$str_Src 	= Common\clean_Path($GLOBALS["InstallBase"]."/PHP_Log/Code/Abstract_Classes");
	$str_Dst	= Common\clean_Path($GLOBALS ["InstallPath"]."/Abstract_Classes");
	Common\recurse_copy($str_Src,$str_Dst);
	
	//Copy Classes
	$str_Src 	= Common\clean_Path($GLOBALS["InstallBase"]."/PHP_Log/Code/Classes");
	$str_Dst	= Common\clean_Path($GLOBALS ["InstallPath"]."/Classes");
	Common\recurse_copy($str_Src,$str_Dst);
	
	//Copy Update Code
	$str_Src 	= Common\clean_Path($GLOBALS["InstallBase"]."/PHP_Log/Setup/Update");
	$str_Dst	= Common\clean_Path(dirname($GLOBALS ["InstallPath"])."/Setup/Update");
	Common\recurse_copy($str_Src,$str_Dst);
}
?>